package my.diplom.dao.service;

import my.diplom.dao.IUserDAO;
import my.diplom.entity.User;
import my.diplom.entity.Resource;
import my.diplom.exceptions.UserNotFoundException;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: gb
 * Date: 14.07.2009
 * Time: 17:28:37
 * To change this template use File | Settings | File Templates.
 */
public class UserService {

    private IUserDAO userDAO;

    public IUserDAO getUserDAO() {
        return userDAO;
    }

    public void setUserDAO(IUserDAO userDAO) {
        this.userDAO = userDAO;
    }


    public void create(User user) {
        userDAO.create(user);
    }

    public void update(User user) {
        userDAO.update(user);
    }

    public User getById(Long userId) {
        return userDAO.getById(userId);
    }

    public List<User> getAll() {
        return userDAO.getAll();
    }

    public List<User> getAll(boolean initProjects) {
        return userDAO.getAll(initProjects);
    }

    public User getByLogin(String login) throws UserNotFoundException {
        return userDAO.getByLogin(login);
    }

    public void delete(User user) {
        userDAO.delete(user);
    }

    public User getById(Long userId, boolean initProjects) {
        return userDAO.getById(userId, initProjects);
    }

    public List<User> getUsersByResource(Resource resource) {
        return userDAO.getUsersByResource(resource);
    }
}
